package UnitTest.DataStructureTest.arrayAndListTest.arrayOpsTest;

import DataStructure.arrayANDList.arrayOps.BuildTeamByTall;
import Logic.utils.ArrayUtilsImpl;
import Logic.utils.ReadFileTools;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.*;

/**
 * @author liujun
 * @version 1.0
 * @date 2020/7/28
 * @author—Email ljfirst@mail.ustc.edu.cn
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 根据身高重建队列 测试案例
 */
public class BuildTeamByTallTest {

    BuildTeamByTall instance = new BuildTeamByTall();

    @Test
    public void testBySQL() {
        List<int[][]> inputList = ReadFileTools.GetIntMatrixList("../TestDataSource/BuildTeamByTallData.md", "demo");
        List<int[][]> outputList = ReadFileTools.GetIntMatrixList("../TestDataSource/BuildTeamByTallData.md", "target");

        for (int i = 0; i < Objects.requireNonNull(inputList).size(); i++) {
            int[][] answer = instance.solution(inputList.get(i));
            assert ArrayUtilsImpl.IntMatrixEquals(answer, Objects.requireNonNull(outputList).get(i));
        }
    }

    @Test
    public void test() {
        List<int[][]> demoMatrixList = ReadFileTools.GetIntMatrixList("../TestDataSource/BuildTeamByTallData.md", "demo");
        List<int[][]> targetMatrixList = ReadFileTools.GetIntMatrixList("../TestDataSource/BuildTeamByTallData.md", "target");

        for (int i = 0; i < Objects.requireNonNull(demoMatrixList).size(); i++) {
            int[][] answer = instance.solution(demoMatrixList.get(i));
            assert ArrayUtilsImpl.IntMatrixEquals(answer, Objects.requireNonNull(targetMatrixList).get(i));
        }
    }

    @Test
    public void testsolution1() {
        int[][] answer = instance.solution1(demo01);
        assert ArrayUtilsImpl.IntMatrixEquals(answer, target01);
        answer = instance.solution1(demo02);
        assert ArrayUtilsImpl.IntMatrixEquals(answer, target02);
        answer = instance.solution1(demo03);
        assert ArrayUtilsImpl.IntMatrixEquals(answer, target03);
        answer = instance.solution1(demo04);
        assert ArrayUtilsImpl.IntMatrixEquals(answer, target04);
        answer = instance.solution1(demo05);
        assert ArrayUtilsImpl.IntMatrixEquals(answer, target05);
    }

    int[][] demo01 = {{4, 4}, {6, 1}, {7, 1}, {5, 0}, {7, 0}, {5, 2}};
    int[][] target01 = {{5, 0}, {7, 0}, {5, 2}, {6, 1}, {4, 4}, {7, 1}};
    int[][] demo02 = null;
    int[][] target02 = {};
    int[][] demo03 = {};
    int[][] target03 = {};
    int[][] demo04 = {{22, 2}, {9, 1}, {7, 0}, {3, 4}, {2, 1}, {11, 4}, {4, 0}, {34, 0}, {12, 0}, {72, 0}};
    int[][] target04 = {{4, 0}, {2, 1}, {7, 0}, {12, 0}, {9, 1}, {3, 4}, {34, 0}, {72, 0}, {22, 2}, {11, 4}};
    int[][] demo05 = {{9, 0}, {7, 0}, {1, 9}, {3, 0}, {2, 7}, {5, 3}, {6, 0}, {3, 4}, {6, 2}, {5, 2}};
    int[][] target05 = {{3, 0}, {6, 0}, {7, 0}, {5, 2}, {3, 4}, {5, 3}, {6, 2}, {2, 7}, {9, 0}, {1, 9}};
}
